﻿using System;

using System.Collections.Generic;
using System.Text;
using Silvermoon.Visuals;
using System.Drawing;
using Silvermoon.OpenGL.Native;

namespace Silvermoon.Visuals
{
    public class RectangleVisual : Visual
    {
        public virtual Color Color { get; set; }

        protected override Color GetPrimitiveColor()
        {
            return Color;
        }

        public override void Render(Silvermoon.Core.Renderer renderer)
        {
            Size r = Size;
            short right = (short)(r.Width);
            short bottom = (short)(r.Height);

            short[] rectangleVertex = new short[] 
                    { 
                        right, bottom,
                        right, 0,
                        0, bottom,
                        0, 0 
                    };

            gl.DisableClientState(ClientStateArray.TextureCoord);
            gl.Disable(Capability.Texture2D);
            gl.VertexPointer(2, glValueType.Short, 0, rectangleVertex);
            gl.DrawArrays(PrimitiveType.TriangleStrip, 0, rectangleVertex.Length / 2);
            gl.EnableClientState(ClientStateArray.TextureCoord);
            gl.Enable(Capability.Texture2D);

        }

    }
}
